import {NavController, ToastController} from '@ionic/angular';
import {UrlAndOPT} from './url-and-opt.enum';
import {AppConfig} from './app-config.enum';

/**
 * 基础页面类，包含显示消息和返回操作
 */
export class BasePage {

  public HOST = UrlAndOPT.HOST;

  constructor(public navCtrl: NavController,
              public toastCtrl: ToastController
  ) {
  }

  async showToast(txt: string) {
    const toast = await this.toastCtrl.create({
      message: txt,
      position: AppConfig.TOAST_POSITION,
      duration: AppConfig.TOAST_DURATION * 1
    });
    return toast.present();
  }

  goBack() {
    this.navCtrl.back();
  }

  doPop() {
    this.navCtrl.pop();
  }

}
